import axios from "axios";

export default function ajax(url, data = {}, type = 'GET') {
    type = type.toUpperCase();
    if (type == 'GET') {
        return axios({
            'url': url,
            'params': data
        })
    } else if (type == 'POST') {
        // console.log('POST');
        return axios({
            'url': url,
            'method': 'post',
            'data': data
        })
    } else if (type == 'DElETE') {
        return axios.delete({
            'url': url + '/' + data,
            'method': 'delete',
        })
    } else if (type == 'PATCH') {
        return axios({
            'url': url,
            'method': 'patch',
            'data': data
        })
    } else if (type == 'PUT') {
        return axios({
            'url': url,
            'method': 'put',
            'data': data
        })
    }
}